home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / CAPITALS.PL < prev    next >
Text File  |  1991-10-31  |  953b  |  34 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5.  
  6. /* CAPITALS.PL */
  7. /* Example of a program that starts computation
  8.    automatically upon being consulted */
  9. /* Quintus Prolog prints a warning at the end of the consultation
  10.    because of the fail statement */
  11.  
  12. capital_of(georgia,atlanta).
  13. capital_of(california,sacramento).
  14. capital_of(florida,tallahassee).
  15. capital_of(connecticut,hartford).
  16.  
  17. print_a_capital :-  capital_of(State,City),
  18.                     write(City),
  19.                     write(' is the capital of '),
  20.                     write(State),
  21.                     nl.
  22.  
  23. print_capitals :-   print_a_capital,
  24.                     fail.
  25.  
  26. /* In some Prologs, change ":-" to "?-" below */
  27.  
  28. :- nl,
  29.    write('The following are some states and their capitals:'),
  30.    nl,
  31.    nl,
  32.    print_capitals.
  33.  
  34.